<div class="modal-header">
	<button type="button" class="close" data-dismiss="modal" aria-label="Close">
		<span aria-hidden="true">&times;</span>
	</button>
	<h5 class="modal-title" id="addModalLabel">添加</h5>
</div>
<form id="addForm" role="form" class="form-horizontal parsley-form" data-parsley-validate action="${base}/platform/paysetting/addDo" method="post">
	<div class="modal-body">   
    	<div class="row mb10">
        	<div class="col-lg-12">
         		<div class="form-group">
              		<label for="product_id" class="col-sm-2 control-label">主体</label>
							
                 	<div class="col-sm-8">
                  		<select id="company_id" name="company_id" class="form-control" >
                        	<%for(company in obj.companyList){%>
                            	<option value="${company.id}">${company.name}</option>
                           	<%}%>
                       	</select>
                  	</div>
               	</div>
              	<div class="form-group">
                	<label for="product_type" class="col-sm-2 control-label">产品类型</label>
                   	<div class="col-sm-8">
                       	<select id="product_type" name="product_type" class="form-control" >
                           	<%for(product in obj.productTypeList){%>
                               	<option value="${product.id}">${product.name}</option>
                            <%}%>
                       </select>
                   	</div>
               	</div>
              	<div class="form-group">
                	<label for="app_scene" class="col-sm-2 control-label">应用</label>

               		<div class="col-sm-8">
                   		<%for(appScene in obj.appSceneList){%>
                     		<input type="radio" name="app_scene" required="required" value="${appScene.id}" onclick="chooseAccount(this.value)" />${appScene.name}
                    	<%}%>
                  	</div>
              	</div>
            	<div class="form-group">
                	<label for="account_id" class="col-sm-2 control-label">账号</label>
                  	<div class="col-sm-8">
                   		<select id="account_id" name="account_id" class="form-control" >
                                		
                   		</select>
               		</div>
          		</div>
     		</div>
    	</div>
  	</div>
	<div class="modal-footer">
		<button  class="btn btn-default btn-sm btn-parsley" >完成</button> 
	</div>
</form>
<script language="JavaScript">
	$(document).ready(function () {
		var dialog=$("#addModal");
		$("#addModalDialog").draggable();
	    $('#addForm').ajaxForm({
	        dataType: 'json',
	        beforeSubmit: function (arr, form, options) {
	        },
	        success: function (data, statusText, xhr, form) {
	            if (data.code==0) {
	                Toast.success(data.msg);
	                datatable.ajax.reload();
	                dialog.modal("hide");
	            } else {
	            	Toast.error(data.msg);
	                datatable.ajax.reload();
	                dialog.modal("hide");
	            }
	        }
	    });
	}); 
    
    //账号选择
    function chooseAccount(value){
    	$.ajax({
			url : "${base}/platform/paysetting/getAccountWithType",
			data : {
				app_scene : value
			},
			type : "post",
			async : false,
			dataType : "json",
			success : function(data){
				var html="";
				for(var i=0;i<data.length;i++){
					html+=' <option value="'+data[i].id+'">'+data[i].name+'</option>';
				}
				$("#account_id").html(html);
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				return false;
			}
		});
    }
</script>
